<?php
  require_once('library.php');
  // Check if the catalog has childs
  $sql = 'SELECT id FROM `containers` WHERE parentId = 0 AND dbId = ?';
  $result = $dbRead->fetchAll($sql,$_GET['dbId']);
  $size_of_result = sizeof($result);
  if ($size_of_result == 0){
	  // The container has no childs 
	  $dbWrite->delete('databases','dbID='.$_GET['dbId']);
	  header('Location: ../DBList.php');
	  break;
	  
  }
  // There are childs, do not delete
  header('Location: ../DBList.php?msg=CatalogNotEmpty');
?>
